package com.zeny.online.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zeny.online.entity.ChatMsg;
import com.zeny.online.mapper.ChatMsgMapper;
import com.zeny.online.service.ChatMsgService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 */
@Service
public class ChatMsgServiceImpl extends ServiceImpl<ChatMsgMapper, ChatMsg> implements ChatMsgService {

    /**
     * @param ids
     * @return void
     * @Description 批量签收消息
     **/
    @Transactional
    @Override
    public void batchSign(List<String> ids) {
        baseMapper.batchSign(ids);
    }

    /**
     * @Description 获取未签收消息
     * @param acceptUserId
     * @return java.util.List<com.zeny.online.entity.ChatMsg>
     **/
    @Override
    public List<ChatMsg> getMyUnsignChatMsg(String acceptUserId) {
        QueryWrapper<ChatMsg> wrapper = new QueryWrapper<>();
        wrapper.eq("accept_user_id", acceptUserId);
        wrapper.eq("sign_flag", 0);
        wrapper.orderByAsc("create_time");
        return baseMapper.selectList(wrapper);
    }
}
